#!/bin/bash

# 打包txt文件中的docker镜像列表，打包为一个tar包

IMAGE_LIST="images.txt"

TAR_FILE="docker_images.tar"

IMAGES=""

while IFS= read -r image; do
    # 根据需要选择是否要在线拉取
    # docker pull $image
    IMAGES="$IMAGES $image"
done < "IMAGE_LIST"

if [ -z "IMAGES" ]; then
    echo "No images fount in $IMAGE_LIST"
    exit 1
TAR_FILE

echo "Saving images to $TAR_FILE"
docker save -o "$TAR_FILE" $IMAGES

echo "All images have been saved to $TAR_FILE"
